package cc.verywell.pureblock.effictive;

import static org.junit.jupiter.api.Assertions.*;

import java.util.ArrayList;
import java.util.Collections;

import org.junit.jupiter.api.Test;

/**
* 
* Copyright © 2019 TanYaqiu. All rights reserved.
* @author TanYaqiu 
* @address flat 601
* @date 2019年6月8日 下午1:54:41
*/
class none {

	@Test
	void test() {
		int a = 512*1024;
		int b = 1;
		int m = 42,n = 3;
		ArrayList<Integer> al = new ArrayList<Integer>();
		while(b*m+n<a) {
			al.add(b++);
		}
		int e = 1024;
		Collections.sort(al, (c,d)->{
			int f;
			int g = c*m+n;
			f = e;
			do {
				f <<= 1;
				if(f>=g) {
					g = f-g;
					break;	
				}
			}while(f<g);
			int h = d*m+n;
			f = e;
			do {
				f <<= 1;
				if(f>=h) {
					h = f-h;
					break;	
				}
			}while(f<h);
			
			return g-h;
		});
		
		for(int i = 0;i<50;i++) {
			double c = al.get(i);
			System.out.print((int)c);
			System.out.print(" - ");
			int f;
			int g = (int)c*m+n;
			f = e;
			do {
				f <<= 1;
				if(f>=g) {
					g = f-g;
					break;	
				}
			}while(f<g);
			System.out.print(g);
			System.out.print(" - ");
			System.out.print(c*(a-1)/1024/1024/1024);
			System.out.println(" Gb");
		}
		
//		for(int i = 0;i<20;i++) {
//			System.out.print(i);
//		System.out.print(':');
//		System.out.print((i - 1) / 2);
//		System.out.print(':');
//		System.out.println((i *2) + 1);
//		}
	}
}
